package com.alibaba.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface TopFaceMapper {

    @Select(value = "select t.userId from rank t order by t.faceValue DESC limit 0,1")
    int findTopValue();

    @Select(value = "select t.faceValue from rank t where t.userId = #{userId} order by t.faceValue DESC limit 0,1")
    float findPersonalTopValue(@Param("userId") int userId);

    @Select(value = "select count(faceValue) from (select r.faceValue from rank r where r.userId=#{userId}) as a")
    int findRecords(int userId);

    @Select("select u.userName from user u where u.userId = #{userId}")
    String name(int userId);

    @Select("select u.avatar from user u where u.userId = #{userId}")
    String ava(int userId);

}
